package com.lucun.es_transaction.controller;

import com.lucun.es_transaction.config.RolePermission;
import com.lucun.es_transaction.entity.UserInfo;
import com.lucun.es_transaction.service.UserInfoService;
import com.lucun.es_transaction.util.AuthorityUtil;
import com.lucun.es_transaction.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/userInfo")
public class UserInfoController {

    @Autowired
    UserInfoService userInfoService;

    //添加用户个人信息
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/insert")
    public JsonResult<?> insert(@RequestBody UserInfo record,HttpServletRequest request){
        return  userInfoService.insert(record,request);
    }

     //解析tokenNumber
     @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/SelectByNumber")
    public UserInfo SelectByNumber(HttpServletRequest request){
        return userInfoService.findByNumber(request);
    }

    //修改个人信息
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/updateByPrimaryKeySelective")
    public JsonResult<?> updateByPrimaryKeySelective(@RequestBody UserInfo record,HttpServletRequest request){
        return userInfoService.updateByPrimaryKeySelective(record,request);
    }

    //根据ID修改实名认证状态
    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/update")
    public JsonResult<?> DeleteById(@RequestBody UserInfo userInfo,HttpServletRequest request){
        return userInfoService.update(userInfo,request);
    }
}
